/* io */

#include "bio.h"

int defaultfiller(IGT* i) {
//	printf("filler\n");
	int nread = fread(i->buff, 1, IBUFFSIZE, i->f);
	if(nread == 0) {
		return EOI;
	}
	i->u = nread - 1;
	i->pos = i->buff;	/* set to the first position */
	/*	for(k = 0; k < nread; k++){
			printf("%c|", i->buff[k]);
		}
		printf("\n");
	*/
	return *(i->pos++);
}

IGT* iopen(IGT* i, FILE* file, char* filename) {
	if(file == NULL) return NULL;
	i->f = file;
	i->filename = filename;
	i->fillbuff = defaultfiller;
	i->u = 0;
	i->pos = i->buff;
	return i;
}
